'use strict';

class BizError extends Error {
  constructor({ errorCode, errorReason, errorReasonSupplement }) {
    super(JSON.stringify({ errorCode, errorReason, errorReasonSupplement }));
    this.name = 'BizError';
    this.errorCode = errorCode;
    this.errorReason = errorReason;
    this.errorReasonSupplement = errorReasonSupplement;
  }
}

const ERROR_INFO_ENUM = {
  // 请检查租车流程
  INVALID_PROCESS: { errorCode: 'INVALID_PROCESS', errorReason: '请检查租车流程' },
  NOT_INSPECTED: { errorCode: 'NOT_INSPECTED', errorReason: '未验车，无法还押金' },
};

module.exports = {
  BizError,
  ERROR_INFO_ENUM,
};
